﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace wpf.Triage.Convert
{
    public class CheckBoxConvert : IValueConverter
    {
        /// <summary>
        /// 数据转显示勾选属性  2022-03-28
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return false;
            }

            return value.Equals(parameter);
        }
        /// <summary>
        /// 勾选属性转数据  2022-03-28
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool bl && bl)
            {
                return parameter;
            }
            return "";
        }
    }
}
